﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace chap16 {
    class Program {
        private static void Main(string[] args) {
            Console.WriteLine("Chap 16");
//            ImplicitlyTypedVariable();

//            PrintThreeStrings();

            InvokeMembersOnDynamicData();
            Console.ReadLine();
        }

        private static void InvokeMembersOnDynamicData() {
            String temp = "rrr";
            dynamic textData1 = "Hello";
            Console.WriteLine(temp.ToUpper());
            Console.WriteLine(textData1.ToUpper());
            Console.WriteLine("");

            // You would expect compiler errors here!
            // But they compile just fine.
            Console.WriteLine(textData1.toupper());
            Console.WriteLine(textData1.Foo(10, "ee", DateTime.Now));
        }


        private static void PrintThreeStrings() {
            var s1 = "Greetings";
            object s2 = "From";
            s2 = 15;
            s2 = false;
            dynamic s3 = "Minneapolis";
            s3 = 22;
            Console.WriteLine("s1 is of type: {0}", s1.GetType());
            Console.WriteLine("s2 is of type: {0}", s2.GetType());
            Console.WriteLine("s3 is of type: {0}", s3.GetType());
        }


        public static void ImplicitlyTypedVariable() {
            var a = new List<int>();
            a.Add(91);
        }
    }
}